package so.wy.servicecenter.businessbed.api.pay;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import so.wy.servicecenter.base.exception.WebException;
import so.wy.servicecenter.base.frame.api.AbstractTokenHttp;
import so.wy.servicecenter.base.frame.api.httpexception.HttpExceptionHandler;
import so.wy.servicecenter.businessbed.web.pay.PayOptWeb;

@RestController
@Scope("request")
@RequestMapping("/pay/opt")
public class PayOptHttp extends AbstractTokenHttp {
    @Autowired
    private PayOptWeb payOptWeb;

    @HttpExceptionHandler
    @PostMapping("/dotx")
    public String doWithDraw(Long rentUserId) throws WebException {
        payOptWeb.doWithDraw(rentUserId);

        return toHttpJson();
    }

    //押金充值
    @HttpExceptionHandler
    @PostMapping("/charge/token")
    public String yjczPre() throws WebException {
        return toHttpJson(payOptWeb.yjczPre(getUserId()));
    }

    //押金体现
    @HttpExceptionHandler
    @PostMapping("/withdraw/token")
    public String yjtx() throws WebException {
        payOptWeb.yjtx(getUserId());
        
        return toHttpJson();
    }
}
